<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>考勤业务申请</title>
		<link rel="stylesheet" href="../static/css/xadmin.css">
		<link rel="stylesheet" href="../static/css/xadmin.css">
		<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="../static/lib/layui/layui.js" charset="utf-8"></script>
		<script type="text/javascript" src="../static/js/xadmin.js"></script>
		<script src="../static/js/my.js"></script>
	</head>
	<body>
		
		
		<!-- 表单回显过去已申请的数据 -->
		<h1 align="center">已申请的记录</h1>
		<table  class="layui-table">
		    <thead>
		    <th>编号</th>
		    <th>姓名</th>
		    <th>考勤类型</th>
			<th>申请时间</th>
			<th>处理人</th>
			<th >状态</th>
		    </thead>
		    <tbody>
		   
		    </tbody>
		</table>
		<!-- 显示页码信息的div -->
		<div align="center">
		   <button type="button" class="layui-btn layui-btn-radius layui-btn-warm"onclick="pre()">
		      <i class="layui-icon">&#xe603;</i>
		    </button>
		    <button type="button" class="layui-btn layui-btn-radius layui-btn-warm"onclick="next()">
		       <i class="layui-icon">&#xe602;</i>
		     </button>
		    当前第<span id="cur"></span>页
			共<span id="total"></span>条申请
		    共<span id="totalPage"></span>页
		    
			
		</div>
		<hr />
		
		<button class="layui-btn layui-btn-radius layui-btn-warm"  type="button" onclick="apply()">发起申请</button>
	</body>
</html>


<script>
	// 主要功能:增加与删除
	//文档加载事件
	$(function(){
			//在文档加载时查询所有考勤记录
			selectByName();
		})
	
	
	
	
	
	//
	var isHandle="no";
	var userName="小王子";
	var id="111";
	//页码数:
	var page=1;
	var row=8;
	//上一页/下一页
	var prePage=0;
	var nextPage=0;
	//上一页
	function pre()
	{
		page=prePage;
		selectByName();
	}
	//下一页
	function next()
	{
		page=nextPage;
		selectByName();
	}
	
	
	
	//定义文档加载事件,回显用户已申请的数据
	
	function selectByName()
	{
		$.ajax({
				url:address+"/check/selectByNameAjax",
				type:"get",
				data:{"page":page,"row":row,"userName":userName},
				dataType:"json",
				success:function (data) {
				  var html="";
				  var handleHtml="";
				  //遍历分页数据,拼接字符串
				  for(var i=0;i<data.list.length;i++)
				  {
					  if(data.list[i].isHandle=="no"||data.list[i].isHandle==null)
					  {
						  handleHtml="<td><font  color='red'>未处理</font></td>";
						  data.list[i].bossName="";
					  }else
					  {
						  handleHtml="<td>已处理</td>";
					  }
					   html+="<tr>"
								+"<td>"+data.list[i].userId+"</td>"
								+"<td>"+data.list[i].userName+"</td>"
								+"<td>"+data.list[i].type+"</td>"
								+"<td>"+data.list[i].time+"</td>"
								+"<td>"+data.list[i].bossName+"</td>"
								+handleHtml
							  +"</tr>"
				  }
				  $("tbody").html(html);
				  
				  if(data==null)
				  {
					  $("#total").text("0");
					  $("#totalPage").text("0");
					  $("#cur").text("0");
				  }else
				  {
					  $("#total").text(data.total);
					  $("#totalPage").text(data.totalPage);
					  $("#cur").text(data.cur);
				  }
				  prePage=data.pre;
				  nextPage=data.next;
				
				        }
				    })
		
	}
	
	
	//发起申请(跳转至申请弹窗)
	function apply()
	{
		
		x_admin_show("发起申请","user-apply.html?userId="+id+"&userName=小王子",500,500);

	}
	
	
	
	
</script>
